// VBlockBuilder.h
// define VBlockBuilder interface
#ifndef VBLOCKBUILDER_H
#define VBLOCKBUILDER_H

#include "crossbit/common.h"

namespace crossbit {

    class VInst;
    class VBlock;

    class VBlockBuilder {
		private:
			//add by zhunan
			int VBlock_Counter;//we use this value to identify the vblocks
        public:
            VBlockBuilder();
            virtual ~VBlockBuilder();

            // --------------------------------------------------
            // Interface of VBlockBuilder
            // --------------------------------------------------

            // prepare the construction of a new VBlock
            // "pc" specify the entry address associated with the block
            virtual void getReady(XTMemAddr pc);

            // Added by Zhang Yichao for CFG
            virtual void getReady(XTMemAddr enter_pc, XTMemAddr next_pc);

            // add new VInstruction "inst" into the block
            virtual void add(VInst *inst);

            // return whether it's the end of the block
            virtual bool isEnd();

            // Added by Zhang Yichao for CFG
            virtual bool isEnd(XTMemAddr pc);

            // pack the block and hand it over to caller
            // "pc" specify the entry address of the next instruction following
            virtual VBlock *wrapUp(XTMemAddr pc);


            inline XTRegNum allocVReg() {
                return bb_vreg++;
            }

        protected:
            VBlock *bb_vblock;
            XTUint8 bb_vreg;	    // initialized with 1

    };
}

#endif
